/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycity.util;

/**
 *
 * @author celikeins
 */
public class StringEncode {
    public static String encode(String s){
       return s.replace(" ", "%20").
                replace("#", "%23").
                replace(".","%2E").
                replace("|", "%7C");
    }
    
    public static String toTag(String[]tags){
        StringBuilder sb = new StringBuilder();
        for(String t:tags){
            sb.append("#");
            sb.append(t);
            sb.append(" ");
        }
        int len=sb.length();
        if(len>0)
            sb.setLength(len-1);
        return sb.toString();
    }
    
    public static String[] toTagArray(String s){
        if(s.length()>0)
            s = s.substring(1);
        return s.split(" #");
    }
}
